<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>遍历Map类型数据</title>
</head>
<body>
    <script>
        let map = new Map([["name","xiasnn"],["age",18]]);
        map.set("able","full");
        // 遍历所有的键
        console.log(map.keys());
        // 遍历所有的值
        console.log(map.values());
        // 遍历所有的键值
        console.log(map.entries());


        // for...of...遍历
        // 遍历所有的键
        for (const key of map.keys()) {
            console.log(key);
        }
        // 遍历所有的值
        for (const value of map.values()) {
            console.log(value);
        }
        // 遍历所有的键值
        for (const [key,value] of map.entries()) {
            console.log(key,value);
        }


        // forEach遍历
        map.forEach(function (value,key) {
            console.log(value,key);
        })
    </script>
</body>
</html>